<%- partial('header') %>
<div class="sui-row">
    <div class="span4"></div>
    <div class="span4" style="border:1px solid #ddd;padding:10px 20px;">
        <h1 style="color:#ccc; border-bottom:3px solid #ddd;margin-bottom:20px;">用户登录</h1>
        <form class="sui-form form-horizontal">
            <div class="control-group">
                <label for="userName" class="control-label">用户名：</label>
                <div class="controls">
                    <input type="text" id="userName" placeholder="用户名">
                </div>
            </div>
            <div class="control-group">
                <label for="userPwd" class="control-label">密码：</label>
                <div class="controls">
                    <input type="password" id="userPwd" placeholder="密码">
                </div>
            </div>
            <!--<div class="control-group">
                <label class="control-label"></label>
                <div class="controls">
                    <label data-toggle="checkbox" class="checkbox-pretty inline">
                        <input type="checkbox" name="remember-me"><span>记住我</span>
                    </label>
                </div>
            </div>-->
            <div class="control-group">
                <label class="control-label"></label>
                <div class="controls">
                    <button type="button" class="sui-btn btn-primary" id="btnLogin">登录</button>
                </div>
            </div>
        </form>
    </div>
    <div class="span4"></div>
</div>
<script>
    $(function () {
        $("#btnLogin").click(function () {
            if ($('#userName').val() && $('#userPwd').val()) {
                $.post("/api/user/login", {
                    userName: $('#userName').val(),
                    userPwd: $('#userPwd').val()
                }, function (data, status) {
                    if (status && data.status) {
                        window.localStorage.UserId = data.result.UserId
                        window.localStorage.UserName = data.result.UserName
                        window.localStorage.Token = data.result.Token
                        window.location.href = '/user'
                    } else {
                        $.confirm({
                            body: '用户名或密码错误,登录失败!'
                        })
                    }
                })
            } else {
                $.confirm({
                    body: '用户名和密码不能为空!'
                })
            }
        })
        $("#btnValid").click(function () {
            $.post("/api/user/info", {
                id: $('#userId').val(),
                access_token: $('#token').val()
            }, function (data, status) {
                console.log(data, status)
            })
        })
    })
</script>
<%- partial('footer') %>